package com.cskaoyan.exception;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionResolver {

    @ExceptionHandler(ValidationException.class)
    @ResponseBody
    public BaseRespVo validationException (ValidationException e){
        return BaseRespVo.error(e.getMessage());
    }

    @ExceptionHandler(ParamValidationException.class)
    @ResponseBody
    public BaseRespVo illegalParamException(ParamValidationException e){
        return  BaseRespVo.error("id须为整数  " + e.getMessage());
    }
}
